<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>选择图标</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <link rel="stylesheet" href="/static/admin/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/common/css/base.css" media="all">
    <link rel="stylesheet" href="/static/common/plugins/font-awesome/css/font-awesome.min.css" media="all">
</head>
<style>

.layui-form{
    padding:0 0 10px 10px;
}
    .layui-form .layui-form-item .layui-input-inline {
        width: 54px;
        padding: 10px;
        text-align: center;
        font-size: 20px;
    }
    .layui-form .layui-form-item .layui-input-inline:hover {
        cursor: pointer;
        background: #108cee;
        color:#ffffff;
    }
    .search{
        padding:10px;
        background: #eee;
    }
</style>
<body>
    <form method="get" action="{{route('admin.icons')}}">
        <div class="layui-form-item search">
            <div class="layui-input-inline">
                <input type="text" name="filter" value="{{$filter}}" id="filter" autocomplete="off" placeholder="请输入图标名称" class="layui-input">
            </div>
            <div class="layui-input-inline">
                <button type="submit" class="layui-btn layui-btn-big">查询</button>
            </div>
        </div>
    </form>
    <div class="layui-form">
        <div class="layui-form-item">
            @foreach ($icons as $val)
            <div class="layui-input-inline" onclick="selectIcon(this)">
                <i class="fa {{$val->name}}" data-name="{{$val->name}}" data-id="{{$val->id}}" data-desc="{{$val->desc}}"></i>
            </div>
            @endforeach
        </div>
    </div>
    <script src="/static/admin/layuiadmin/layui/layui.js"></script>
<script>
    layui.use(['layer', 'form'], function () {
        var form = layui.form,
            layer = layui.layer, //独立版的layer无需执行这一句
            $ = layui.$;
        window.selectIcon = function(obj){
            parent.callback($(obj).find('i').attr('data-name'));
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        }
        $('.layui-form .layui-form-item .layui-input-inline').hover(function(){
            var descs = $(this).find('i').attr('data-desc');
            if(descs){
                var descs = descs.replace(/,/g," ");
                layer.tips(descs, $(this), { tips: 3 });
            }
        })

    })
</script>
</body>
</html>
